/*
 * Copyright (C) 2010-2011 Comcast Cable.  All Rights Reserved.
 */
package com.hercules.android.receiver.handlers.commands;

/**
 * This exception is raised by {@link XRENewCommandHandler} and {@link XRESetCommandHandler} if it encounters any
 * command parameter which has invalid value.
 * <p>
 * Note the exception will only be propagated to {@link XREAggregateCommandHandler} and then processed by
 * {@link XRECommandErrorHandler}. It extends {@link XREObjectCommandHandlerException}.
 * <p>
 * <b>Thread Safety:</b> This class is not thread safe as its base class is not thread safe.
 *
 * @author liuliquan, 7realm
 * @version 1.0
 */
public class InvalidXRECommandParameterException extends XREObjectCommandHandlerException {
    /** Serial version UID. */
    private static final long serialVersionUID = -8307110484891951997L;

    /**
     * The command parameter which has invalid value.
     * <p>
     * Initialized in constructor and will not change after. Can be any value. It has a getter.
     */
    private final String parameter;

    /**
     * The invalid value of the command parameter.
     * <p>
     * Initialized in constructor and will not change after. Can be any value. It has a getter.
     */
    private final Object invalidValue;

    /**
     * Creates a new instance of InvalidXRECommandParameterException with given error message, the command parameter and
     * the invalid value.
     *
     * @param message the error message
     * @param parameter the command parameter which has invalid value
     * @param invalidValue the invalid value of the command parameter
     */
    public InvalidXRECommandParameterException(String message, String parameter, Object invalidValue) {
        super(message);
        this.parameter = parameter;
        this.invalidValue = invalidValue;
    }

    /**
     * Creates a new instance of InvalidXRECommandParameterException with given error message, the cause, the command
     * parameter and the invalid value.
     *
     * @param message the error message
     * @param cause the cause of the exception
     * @param parameter the command parameter which has invalid value
     * @param invalidValue the invalid value of the command parameter
     */
    public InvalidXRECommandParameterException(String message, Throwable cause, String parameter, Object invalidValue) {
        super(message, cause);
        this.parameter = parameter;
        this.invalidValue = invalidValue;
    }

    /**
     * Gets the command parameter which has invalid value.
     *
     * @return the command parameter which has invalid value
     */
    public String getParameter() {
        return parameter;
    }

    /**
     * Gets the invalid value of the command parameter.
     *
     * @return the invalid value of the command parameter
     */
    public Object getInvalidValue() {
        return invalidValue;
    }
}